<%--
 *  File:    CasualConditionReport.jsp
 *  @Author: JackYin
 *  Date:    2011/03/15
 *
 *  Copyright (C) 2000 - 2010 Oval Technologies, Inc.
 *  All rights reserved. 
 *
 *  This software is the confidential and proprietary information of Oval 
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>

<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java"%>
<%@ page import="java.util.*"%>
<%@ page import="org.apache.log4j.Category"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom"%>
<% //--------------------------------------  setting logger --%>
<%
  	Category cat = Category.getInstance("jsp.CasualConditionReport"); 

  //init param
  String strModuleName = "CM";
  String privilegeCode = "R50020";
  String contextPath = request.getContextPath();
%>
<% //--------------------------------------  include files list --%>
<%@ include file="/inc/Security.inc"%>
<%@ include file="/inc/FrmDefault.inc"%>
<%@ include file="/inc/PageDefault.inc"%>
<%@ include file="/inc/LocationDefault.inc"%>

<html>
<head>
<title>CasualConditionReport</title>
<PageFlow:CheckPageFlow pageName="p_nationalsalesreport" />
<link rel="stylesheet"
	href="<%=contextPath %>/css/<%= strLanguageCode %>/main.css"
	type="text/css">
<script language="JavaScript"
	src="<%=contextPath %>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/ScriptLib.js"></script>

<%@ include file="/inc/SummaryDivision.inc"%>
<%@ include file="/rpt/ReportURL.inc" %>
<script>
 function page_reformprovince(){
	 var areaidstr = document.cform.areaidstr.options;
	if(1 < areaidstr.length){
		areaidstr[0] = new Option ('ALL',areaidstr[areaidstr.length - 1].value);
		areaidstr[0].selected = true;
		areaidstr[areaidstr.length -1] = null; 
	}
 }
 
 function page_changezone(){
	var bigzoneid = document.cform.bigzoneid.options[document.cform.bigzoneid.selectedIndex].value;
	if(isEmpty(bigzoneid)){
		document.cform.areaidstr.options[0].value = new Option ('-------','');
		document.cform.areaidstr.disabled = true;
		return;
	}else{
		document.cform.areaidstr.disabled = false;
	}
	var datahandler = new  DataHandler() ;
	datahandler.add_params("parentareaid" , bigzoneid, 'Integer');
	datahandler.getResultFromVector("areas" ,"areaname","areaid","document.cform.areaidstr");
	datahandler.add_job("j_nationalsalesreport");
	datahandler.add_function("page_reformprovince()");
	datahandler.runDataHandler();
 }

function getCheckbox(){
    var r=document.getElementsByName("levels"); 
    var values="";
    for(var i=0;i<r.length;i++){
      if(r[i].checked){
	      values+=","+r[i].value;
      }
   }
     values=values.substring(1);
    document.cform.classvalue.value=values;
     //return values;
   }

 function page_go(){
	 getCheckbox();
	 var classvalue = document.cform.classvalue.value;
	 var statistics = cform.statistics.options[cform.statistics.selectedIndex].value;
	 var partareaname = cform.partareaname.options[cform.partareaname.selectedIndex].value;
	 var areaidstr = cform.areaidstr.options[cform.areaidstr.selectedIndex].value;
     var year = document.cform.years.value;
     var month = document.cform.months.value;
     var bigzoneid = document.cform.bigzoneid.value;
     var bparea = cform.bparea.options[cform.bparea.selectedIndex].value;
    // alert(classvalue+"  ||  "+ statistics+"  ||  "+partareaname+"  ||  "+areaidstr +"  || "+year+"  || "+month+"  ||  "+bigzoneid+);
    if(bparea ==10  && statistics == 10){
    alert("大区和数量");
	var url = "<%= reportURL%>" + "/frameset?__report=/ovalreport/NationalSalesReport.rptdesign&sessionid=<%=session.getId()%>&year=" 
	+ year + "&month=" + month+"&statistics=" + statistics + "&partareaname=" +partareaname + "&classvalue=" +classvalue + "&bigzoneid=" + bigzoneid+"&areaidstr="+areaidstr;
     if(!isEmpty(areaidstr)) url += "&areaidstr=" + areaidstr;
     document.iframe.location.href = url;
    }
    if(bparea ==10  && statistics == 20){
	   alert("大区和百分比");
    }
   if(bparea ==20  && statistics == 10){
	   alert("片区和数量");
    }
   if(bparea ==20  && statistics == 20) {
	   alert("片区和百分比");
    }
  
 }

</script>

<script>
var showplay = true;
function f_select_cst(e){

	　var X= e.getBoundingClientRect().left;
	　var Y =e.getBoundingClientRect().top;
	  var _obj = document.getElementById("cstfrm"); 
	  _obj.style.left = X + 'px';
	  _obj.style.top = (Y+  e.clientHeight + 20) + 'px';
      _obj.style.height="283px";
      _obj.style.width="80px";
      _obj.style.zIndex = 100;
      _obj.style.display = "block";
	  var strUrl = "MonthPopWindow.jsp?<%= OvalTools.randomURL() %>";
      document.cstfrm.location.href = strUrl;
      showplay = true;
     
     
}


function hideMonth(){
	document.getElementById("cstfrm").style.display="none";
}


function page_setMonth(value,valuename) {
	document.cform.monthid.value=value;
    document.cform.months.value=valuename;
}


function hiddendisplay(){ 
	var bparea = document.cform.bparea.options[document.cform.bparea.selectedIndex].value;
	if(bparea==10){
    document.getElementById("bigarea").style.display="block";
     document.getElementById("partarea").style.display="none";
	}else{
		document.getElementById("bigarea").style.display="none";
		document.getElementById("partarea").style.display="block";
	}
}

function closeItemSelect()
{
	var _obj = document.getElementById("cstfrm");
  if (showplay)
	  showplay = false;
  else{
	  _obj.style.display="none";
    }
}

document.onclick = closeItemSelect;   

</script>
</head>
<body>
<iframe id="reloadHandler" name="reloadHandler" style="display: none"></iframe>
<% //--------------------------------------  page location --%>
<%@ include file="/inc/PageLocation.inc"%>
<table width="100%" cellspacing="0" border="0" cellpadding="0">
	<form name="cform" method="post" action="<%=contextPath %>/Dispatcher"
		target="_self"><input type="hidden" name="pagename"
		value="p_nationalsalesreport"> <input type="hidden"
		name="actionname"> <custom:hidden property="processtype" />
		<custom:hidden property="languagecode" scope="session" /> 
	<custom:hidden property="year" />
	<custom:hidden property="classvalue"></custom:hidden>
	<tr>
		<td>
		<table width="100%" border="0" cellspacing="0"
			bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0"
			align="center"
			style="background:url(<%= contextPath %>/images/<%= strLanguageCode %>/title_2_bg.jpg) repeat-x; "
			height="36">
			<tr>
				<% 
         String flag = (String)pageContext.getAttribute("flag");
					java.util.Calendar cal = java.util.Calendar.getInstance();      
					String year = cal.get(Calendar.YEAR)+"";     
					String month = cal.get(Calendar.MONTH)+"";
					if(cal.get(Calendar.MONTH) == 0){
						month = "12";
						year = (cal.get(Calendar.YEAR)-1)+"";
					}  
					if("first".equals(flag)){ 
				%>
				<td width="10%" class="td_right">&nbsp;</td>
				<td class="td_right" width="6%">年份 <font color="red">*</font>：</td>
				<td width="5%"><custom:selectdic property="years"
					dictType="Years" command="notnull" value="<%=year %>"
					label="L_Year1" /></td>
				<td class="td_right" width="6%">月份 <font color="red">*</font>：</td>
				<td width="7%"><custom:text property="months" size="5" readonly="true"/> <custom:hidden
					property="monthid" /> <a onClick="f_select_cst(this)"><custom:button
					type="3" label="L_Asterisk" imgsrc="flash.gif" border="0" /></a> 
				</td>
                   <iframe name="cstfrm" scrolling="no" frameborder="0" style="position: absolute; top: 0px; left: 0px; display: none; border: #909eff 1px solid;"></iframe>

				<%}else{ %>
				<td class="td_right" width="6%">年份 <font color="red">*</font>：</td>
				<td width="5%"><custom:selectdic property="years"
					dictType="Years" command="notnull" label="L_Year1" /></td>
				<%} %>
                	<td class="td_right" width="6%">区域 <font color="red">*</font>：</td>
				<td width="5%"><select name="bparea" onchange="hiddendisplay();">
				<option value="10">大区</option>
				<option value="20" selected>片区</option>
				</select></td>
			<td>
			<div id="bigarea" style="display:none;">
			<table><tr>
				<td class="td_right" width="6%">大区 ：</td>
				<td width="5%"><custom:select optionInnerTextKey="areaname"
					optionsName="areas" optionValueKey="areaid" property="bigzoneid"
					defaultValue="ALL" defaultValueCost="" onchange="page_changezone()" /></td>
				<td class="td_right" width="6%">省区 ：</td>
				<td width="5%"><select name="areaidstr" disabled="disabled">
					<option value="">----------</option></td>
					</tr></table></div>
					
					
					<div id="partarea" style="display:block;">
			<table><tr>
		
				<td class="td_right" width="6%">片区 ：</td>
				<td width="5%"><custom:selectdic dictType="SmallArea" property="partareaname"/></td>
					<td class="td_right" width="4%">&nbsp;</td>
					<td width="1%">&nbsp;</td>
					</tr></table></div>
					</td>
			
				<td class="td_right" width="6%">统计项：</td>
				<td width="5%"><custom:selectdic dictType="Statistics"
					property="statistics" /></td>
				<%--
				<td class="td_right" width="8%"><%= label.getLabelName("L_DealersLevel")%>
				<font color="red">*</font>：</td>
				<td width="8%"><custom:selectdic dictType="DealersLevel"
					property="dtlevel1" /></td>
				 --%>
				
				<td class="td_right" width="6%">药店级别：</td>
				<td width="6%">
				<input type="checkbox" name="levels" value="A" style="height:15px;border:0px;">A
				<input type="checkbox" name="levels" value="B" style="height:15px;border:0px;">B<br>
				<input type="checkbox" name="levels" value="C" style="height:15px;border:0px;">C
				<input type="checkbox" name="levels" value="D" style="height:15px;border:0px;">D</td>
				<td width="1%" class="td_right">&nbsp;</td>
				<td><a href="javascript:page_go()"><img
					src="<%= contextPath %>/images/<%= strLanguageCode %>/go_fy.gif"
					border="0" style="border: 1 solid #000000"></a></td>
				<td width="5%" class="td_right">&nbsp;</td>
			</tr>
		</table>
		</td>
	</tr>
	</form>
</table>
<iframe src="<%= contextPath %>/Blank.jsp" frameborder=0 width="100%" height="87%" name="iframe"></iframe>
</body>
</html>